<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

<h:head>
	<link type="text/css" rel="stylesheet" href="#{request.contextPath}/resources/css/styles.css" />
	<title>Registrazione</title>
</h:head>

<h:body>
<div id="header">
	<ui:include src="/resources/snippets/headerOut.xhtml"></ui:include>
</div>
	<h1>Registrazione Nuovo Cliente</h1>
	<br/>
	<h:form>
		<h:outputLabel for="email">Email: </h:outputLabel>
		<h:inputText id="email" value="#{datiUtente.current.email}" />
		<h:message for="email" /> <br/>
		<br/>
		<h:outputLabel for="password">Password: </h:outputLabel>
		<p:password id="password" value="#{datiUtente.current.password}" feedback="true" match="confirmPsw" label="Password"/>
		<p:message for="password" /> <br/>
		<h:outputLabel for="confirmPsw">Conferma Password: </h:outputLabel>
		<p:password id="confirmPsw" label="Conferma Password" value="#{datiUtente.current.password}"/> <br/>
		<br/>
		<h:outputLabel for="nome">Nome: </h:outputLabel>
		<h:inputText id="nome" value="#{datiUtente.current.nome}" />
		<h:message for="nome"></h:message> <br/>
		<br/>
		<h:outputLabel for="Cognome">Cognome: </h:outputLabel>
		<h:inputText id="Cognome" value="#{datiUtente.current.cognome}" />
		<h:message for="Cognome"></h:message> <br/>
		<br/>
		<h:outputLabel for="indirizzo">Indirizzo: </h:outputLabel>
		<h:inputText id="indirizzo" value="#{datiUtente.current.indirizzo}" />
		<h:message for="indirizzo"></h:message> <br/>
		<br/>
		<p:commandButton value="Crea Nuovo" action="#{datiUtente.creaCliente()}" />
	</h:form>
	<p:dialog id="errorReg" header="Email non valida" widgetVar="errReg" modal="true">  
    	<h:outputText value="Attenzione: esiste già un utente registrato con indirizzo email #{datiUtente.current.email}" /> <br/>
    	<p:commandButton id="errorRegButton" value="Ok" onclick="PF('errReg').hide();" type="button"/>  
	</p:dialog>
	<br/>
	<br/>
	<h:link outcome="home" value="Torna alla Home" />
	<br/>
	<br/>
	<br/>
<div id="footer">
	<ui:include src="/resources/snippets/footer.xhtml"></ui:include>
</div>
</h:body>
</html>